package com.data.service.log.impl;

import com.data.domain.log.Systemlog;
import com.data.domain.log.SystemlogCriteria;
import com.data.mapper.log.SystemlogMapper;
import com.data.service.log.SystemlogService;
import com.data.utill.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service(value = "systemlogService")
public class SystemlogServiceImpl implements SystemlogService {

    @Autowired
    private SystemlogMapper systemlogMapper;

    @Override
    public List<Systemlog> getSystemlog(Date start, Date end, String logtype) {
        SystemlogCriteria systemlogCriteria=new SystemlogCriteria();
        SystemlogCriteria.Criteria criteria=systemlogCriteria.createCriteria();
        if(StringUtils.isNoNullString(start)&&StringUtils.isNoNullString(end)){
            criteria.andLogtimeBetween(start,end);
        }
        if(StringUtils.isNoNullString(logtype)){
            criteria.andLogtypeEqualTo(logtype);
        }
        systemlogCriteria.setOrderByClause("workdate desc");
        return systemlogMapper.selectByExample(systemlogCriteria);
    }
}
